# Copyright Bjorn De Meyer 2007. Can be used freely under the zlib license.

module Rogaru::Image

def self.load_file(filename) 
	begin
        surface = Rubygame::Surface.load_image(filename)
    rescue Rubygame::SDLError
        raise "Could not load image #{filename}"
	end	
end 

# Loads an solid image, prepares it for display.
# By default, the colorkey is bright pink (#FF00FF), like in the Allegro game library
def self.load_solid(filename)
	surface = load_file(filename)
	return surface.to_display().set_alpha(255,0)
end	

# Loads an image with a colorkey, prepares it for display.
# By default, the colorkey is bright pink (#FF00FF), like in the Allegro game library
def self.load_colorkey(filename, colorkey = [255,0,255])
	surface = load_file(filename)
    surface.set_colorkey(colorkey)
	return surface.to_display_alpha()
end	

# Loads an image with alpha, prepares it for display.
def self.load_alpha(filename)
	surface = load_file(filename)
	return surface.to_display_alpha()
end	




end # module Image